package com.itheima.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
public interface ReportDao {
    /**
     * 获取所有会员的注册年月日
     * @return
     */
    @Select("select distinct regTime from t_member order by regTime")
    List<LocalDate> getMemberRegTime();

    /**
     * 按天统计新注册会员数
     * @return
     */
    @Select("select count(regTime) from t_member group by regTime")
    List<Integer> countMemberByRegTime();

    /**
     * 统计指定时间注册会员总数
     * @return
     */
    Integer countTotalMemberByRegTime(LocalDate begin, LocalDate end);

    /**
     * 获取所有预约套餐名
     * @return
     */
    @Select("select distinct s.name from t_order o, t_setmeal s where o.setmeal_id=s.id")
    List<String> getSetmealNames();

    /**
     * 统计指定预约套餐数
     * @return
     * @param setmealName
     */
    @Select("select count(o.id) from t_order o, t_setmeal s " +
            "where o.setmeal_id=s.id and s.name=#{setmealName}")
    Integer countSetmealBySetmealName(String setmealName);

    /**
     * 预约数据统计
     * @param begin
     * @param end
     * @param orderStatus
     * @return
     */
    Integer countTotalOrderByOrderDate(LocalDate begin, LocalDate end, String orderStatus);

    /**
     * 获取预约套餐总数
     * @return
     */
    @Select("select count(*) from t_order")
    Integer getTotalSetmeal();
}
